﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;

namespace Foundation.Markup
{
    public class OpacityExtension : MarkupExtension
    {
        public OpacityExtension() : base(new RelativeSource(RelativeSourceMode.Self))
        {

        }
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //(value as Control)
            var control = value as FrameworkElement;
            control.Loaded += (sender, args) =>
            {
                while (true)
                {
                    var parent = VisualTreeHelper.GetParent(value as DependencyObject);
                    if (parent is Button) break;
                    ;
                }
            };
            return true;
            //throw new NotImplementedException();
        }
    }
}
